import { R } from '@/components/axios/interface'
import UpmsMenuAndAuthorityResponse from '@/core/upms/types/model/response/UpmsMenuAndAuthorityResponse'
import http from '@/components/axios/http'
import lodash from 'lodash'
import { AxiosRequestConfig } from 'axios/index'
import serverApiUtils from '@/core/utils/serverApiUtils'
import upmsApiConfig from '@/core/upms/apiconfig/upmsApiConfig'

class UpmsMenuServerApi {
	getAllAdminMenuByCurrentAccount = (token: string): Promise<R<UpmsMenuAndAuthorityResponse[]>> => {
		const config = lodash.merge(
			{
				headers: serverApiUtils.addTokenHeader({}, token),
			} as AxiosRequestConfig,
			serverApiUtils.convertApiConfig(upmsApiConfig.upmsMenu.getAllAdminMenuByCurrentAccount),
		)
		return http.post(config)
	}
}

export default new UpmsMenuServerApi()
